#include "uhm/common.hxx"
#include "uhm/util.hxx"

#include "uhm/discrete/base.hxx"
#include "uhm/discrete/extension.hxx"

#include "uhm/discrete/io/stream2mesh.hxx"
#include "uhm/discrete/io/mesh2stream.hxx"



#define N 1

using namespace uhm;

typedef ID_Node_<N>            Id_Nd;
typedef ID_Element_<N>         Id_El;
typedef Int_                   Uhm;

typedef Mesh_<Id_Nd,Id_El,Uhm> Mesh;

int main (int argc, char **argv) {

  set_option(argc, argv);

  std::string fin, fout;

  option_begin();
  get_option_string("-in", "Reading a file", __FILE__,
                    "../../../uhmfile/toy_1.uhm", fin);

  get_option_string("-out", "Writing a file", __FILE__,
                    "./test.uhm", fout);
  option_end();

  Mesh mesh;

  std::ifstream in;

  std::cout << "Attempting to open file ... " << fin << std::endl;

  in.open(fin.c_str());
  stream2mesh<Mesh>(in, mesh);
  in.close();

  std::cout << mesh;

  std::ofstream out;
  
  std::cout << "Attempting to open file ... " << fout << std::endl;

  out.open(fout.c_str());
  mesh2stream<Mesh>(mesh, 1, 1, 1, out);
  out.close();

  return true;
}


